/*    */ package handling.world.guild;
/*    */ 
/*    */ import handling.world.WorldGuildService;
/*    */ import java.util.Map;
/*    */ import java.util.concurrent.ArrayBlockingQueue;
/*    */ import java.util.concurrent.atomic.AtomicInteger;
/*    */ import org.apache.logging.log4j.LogManager;
/*    */ import org.apache.logging.log4j.Logger;
/*    */ 
/*    */ 
/*    */ 
/*    */ public class GuildLoad
/*    */ {
/*    */   public static final int NumSavingThreads = 6;
/* 15 */   private static final TimingThread[] Threads = new TimingThread[6];
/* 16 */   private static final Logger log = LogManager.getLogger(GuildLoad.class);
/* 17 */   private static final AtomicInteger Distribute = new AtomicInteger(0);
/* 18 */   private static Map<Integer, Map<Integer, MapleBBSReply>> replies = null;
/*    */   
/*    */   static {
/* 21 */     for (int i = 0; i < Threads.length; i++) {
/* 22 */       Threads[i] = new TimingThread(new GuildLoadRunnable());
/*    */     }
/*    */   }
/*    */   
/*    */   public static void QueueGuildForLoad(int hm, Map<Integer, Map<Integer, MapleBBSReply>> replie) {
/* 27 */     int Current = Distribute.getAndIncrement() % 6;
/* 28 */     Threads[Current].getRunnable().Queue(Integer.valueOf(hm));
/* 29 */     if (replies == null) {
/* 30 */       replies = replie;
/*    */     }
/*    */   }
/*    */   
/*    */   public static void Execute(Object ToNotify) {
/* 35 */     for (TimingThread Thread1 : Threads) {
/* 36 */       Thread1.getRunnable().SetToNotify(ToNotify);
/*    */     }
/* 38 */     for (TimingThread Thread : Threads)
/* 39 */       Thread.start(); 
/*    */   }
/*    */   
/*    */   private static class GuildLoadRunnable
/*    */     implements Runnable
/*    */   {
/* 45 */     private final ArrayBlockingQueue<Integer> Queue = new ArrayBlockingQueue<>(1000);
/*    */     
/*    */     private Object ToNotify;
/*    */     
/*    */     public void run() {
/*    */       try {
/* 51 */         while (!this.Queue.isEmpty()) {
/* 52 */           WorldGuildService.getInstance().addLoadedGuild(new MapleGuild(((Integer)this.Queue.take()).intValue(), GuildLoad.replies));
/*    */         }
/* 54 */         synchronized (this.ToNotify) {
/* 55 */           this.ToNotify.notify();
/*    */         } 
/* 57 */       } catch (InterruptedException ex) {
/* 58 */         GuildLoad.log.error("[GuildLoad] 加载家族信息出错." + ex);
/*    */       } 
/*    */     }
/*    */     
/*    */     private void Queue(Integer hm) {
/* 63 */       this.Queue.add(hm);
/*    */     }
/*    */     
/*    */     private void SetToNotify(Object o) {
/* 67 */       if (this.ToNotify == null)
/* 68 */         this.ToNotify = o; 
/*    */     }
/*    */     
/*    */     private GuildLoadRunnable() {}
/*    */   }
/*    */   
/*    */   private static class TimingThread extends Thread {
/*    */     private final GuildLoad.GuildLoadRunnable ext;
/*    */     
/*    */     public TimingThread(GuildLoad.GuildLoadRunnable r) {
/* 78 */       super(r);
/* 79 */       this.ext = r;
/*    */     }
/*    */     
/*    */     public GuildLoad.GuildLoadRunnable getRunnable() {
/* 83 */       return this.ext;
/*    */     }
/*    */   }
/*    */ }


/* Location:              C:\PGX\Server.jar!\handling\world\guild\GuildLoad.class
 * Java compiler version: 8 (52.0)
 * JD-Core Version:       1.1.3
 */